<template>
  <div class="business container">
    <div class="news_title">
      <h3>企业新闻</h3>
      <p>BUSINESS NEWS</p>
    </div>
    <div class="news_top">
      <img src="" alt="">
    </div>
    <ul class="news_list">
      <li v-for="(item,index) in change" :key='index' class="news_content">
        <a :href="'http://www.jztey.com/html/Article/'+item.Url" >{{item.Title}}</a>
      </li>
    </ul>
    <el-pagination
      @current-change="handleCurrentChange"
      :page-size='10'
      background
      layout="pager"
      :total="30">
    </el-pagination>
  </div>
</template>

<script>
import {getNewsData} from 'api/api'
export default {
  data () {
    return {
      list: {},
      change: []
    }
  },
  methods: {
      handleCurrentChange(val) {
        console.log(`当前页: ${val}`)
        this.change = this.list[val]
      }
  },
  mounted () {
    getNewsData()
    .then((res)=>{
      this.list={}
      let data1 = []
      let data2 = []
      let data3 = []
      res[1].list.forEach((item,index) => {
        let obj = {}
        obj.CreateTime= item.CreateTime
        obj.Title=item.Title
        obj.Url=item.Url
        if(index <= 9 && index >0){
          data1.push(obj)
        }else if(index <= 19 && index > 9){
          data2.push(obj)
        }else if(index <= 29 && index > 19){
          data3.push(obj)
        }else{
          this.list[0] = obj
        }
      })
      this.list[1] = data1
      this.list[2] = data2
      this.list[3] = data3
      this.change = []
      this.change = this.list[1]
    })
  }
}
</script>

<style lang="scss" scoped>

</style>
